package com.lbn.jfqsc.app.message;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioGroup;

import com.lbn.baseframe.base.BaseFragment;
import com.lbn.baseframe.utils.L;
import com.lbn.baseframe.widget.FragmentTabAdapter;
import com.lbn.jfqsc.R;
import com.lbn.jfqsc.app.account.AccountFragment;
import com.lbn.jfqsc.app.message.action.ActionFragment;
import com.lbn.jfqsc.app.message.performance.PfmFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MessageFragment extends BaseFragment<MessagePresenter> implements IMessageView {


    @BindView(R.id.time_switch)
    RadioGroup timeSwitch;
    private FragmentTabAdapter tabAdapter;
    //    @BindView(R.id.recycler_view)
//    XRecyclerView recyclerView;
//    private MessageAdapter adapter;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (rootView == null) {
            rootView = inflater.inflate(R.layout.activity_message, null, false);
            ButterKnife.bind(this, rootView);
        }
        return rootView;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
//        getFragmentManager().beginTransaction().replace(R.id.message_replace_view, AccountFragment.newInstance()).commitAllowingStateLoss();
    }


    @Override
    protected void onPresenterCreated() {
        super.onPresenterCreated();

        List<Fragment>list = new ArrayList<>();
//        list.add(ActionFragment.newInstance());
        list.add(PfmFragment.newInstance(1));
        list.add(PfmFragment.newInstance(2));
        tabAdapter = new FragmentTabAdapter(getActivity(),list,R.id.message_replace_view,timeSwitch);
        L.e("MessageFragment");
    }

    public static MessageFragment newInstance() {
        MessageFragment fragment = new MessageFragment();
        return fragment;
    }

    @Override
    public MessagePresenter createPresenter() {
        return new MessagePresenter();
    }

}
